/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.Jogo;

import Biblioteca.Library;
import ClassesListas.Pessoas;
import ClassesUnicas.Pessoa;
import InstanciaJogo.InstanciaJogoSwing;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Image;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 * FrameJogo
 * 
 * Versao 1.0
 * 
 * Data Criação 25/06/2013
 *
 * @author LupyPaiep
 */
public final class FrameJogo extends javax.swing.JFrame {

    //Atributos
    private InstanciaJogoSwing jogo = null;
    private InstanciaJogoSwing jogoTemporario = null;
    private Pessoas pessoas = null;
    private Pessoa jogador = null;

    /**
     * Creates new form FrameJogo
     */
    public FrameJogo() {
        //Desativa Maximizar
        this.setResizable(false);

        initComponents();

        //Centraliza o FrameJogo
        this.setLocationRelativeTo(null);
        
        this.setTitle("Jogo Reconhecimento Facial  - TREF "+Library.getVersaoTREF());

        desativarTodosPanels();
        ativarPanelParametros();

        this.jogoTemporario = new InstanciaJogoSwing(labelImagem, labelStatus, this);
        this.pessoas = new Pessoas();
        this.jogador = new Pessoa();
        
        Library.semCaracterEspecial(textNomeJogadorCadastro);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modifyPai this code. The content of this method is
     * alwayPais regenerated byPai the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelJogo = new javax.swing.JPanel();
        buttonTristeza = new javax.swing.JButton();
        buttonMedo = new javax.swing.JButton();
        labelImagem = new javax.swing.JLabel();
        buttonSurpresa = new javax.swing.JButton();
        buttonRaiva = new javax.swing.JButton();
        buttonNojo = new javax.swing.JButton();
        labelStatus = new javax.swing.JLabel();
        buttonAlegria = new javax.swing.JButton();
        buttonAlegria1 = new javax.swing.JButton();
        buttonTristeza1 = new javax.swing.JButton();
        buttonNojo1 = new javax.swing.JButton();
        buttonMedo1 = new javax.swing.JButton();
        buttonSurpresa1 = new javax.swing.JButton();
        buttonRaiva1 = new javax.swing.JButton();
        buttonPausarJogo = new javax.swing.JButton();
        panelFimJogo = new javax.swing.JPanel();
        textFimDeJogo = new javax.swing.JLabel();
        buttonFinalizarJogo1 = new javax.swing.JButton();
        panelTrocaFaseSubFase = new javax.swing.JPanel();
        buttonIniciarFaseJogo = new javax.swing.JButton();
        labelPercentualAcerto = new javax.swing.JLabel();
        labelEstrela1 = new javax.swing.JLabel();
        labelEstrela2 = new javax.swing.JLabel();
        labelEstrela3 = new javax.swing.JLabel();
        panelParametros = new javax.swing.JPanel();
        buttonConfirmarContinuar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        textTempoApresentacaoImagem = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        textTempoTransicaoImagens = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        textRepetirApresentacaoImagens = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        textPercAvancarSubFases = new javax.swing.JTextField();
        checkBoxApresentarMensagemAcertoErro = new javax.swing.JCheckBox();
        comboBoxModoJogo = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        textNomeJogador = new javax.swing.JTextField();
        buttonSelecaoJogador = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        panelSelecaoJogador = new javax.swing.JPanel();
        buttonNovoJogador = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableJogadores = new javax.swing.JTable();
        buttonSelecionarJogador = new javax.swing.JButton();
        buttonCancelarSelecaoJogador = new javax.swing.JButton();
        panelNovoJogador = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        textCodigoJogadorCadastro = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        textNomeJogadorCadastro = new javax.swing.JTextField();
        buttonSalvarCadastroJogador = new javax.swing.JButton();
        buttonCancelarCadastroJogador = new javax.swing.JButton();
        panelJogoPausado = new javax.swing.JPanel();
        buttonContinuarJogoPausado = new javax.swing.JButton();
        labelJogoPausado = new javax.swing.JLabel();
        buttonFinalizarJogo = new javax.swing.JButton();
        panelIniciarJogo = new javax.swing.JPanel();
        buttonIniciarJogo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Jogo Reconhecimento Facial");
        addWindowStateListener(new java.awt.event.WindowStateListener() {
            public void windowStateChanged(java.awt.event.WindowEvent evt) {
                formWindowStateChanged(evt);
            }
        });

        buttonTristeza.setBackground(new java.awt.Color(51, 51, 255));
        buttonTristeza.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonTristeza.setText("TRISTEZA");
        buttonTristeza.setActionCommand("");
        buttonTristeza.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTristezaActionPerformed(evt);
            }
        });

        buttonMedo.setBackground(new java.awt.Color(255, 255, 0));
        buttonMedo.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonMedo.setText("MEDO");
        buttonMedo.setActionCommand("");
        buttonMedo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonMedoActionPerformed(evt);
            }
        });

        labelImagem.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelImagem.setToolTipText("");

        buttonSurpresa.setBackground(new java.awt.Color(255, 102, 0));
        buttonSurpresa.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonSurpresa.setText("SURPRESA");
        buttonSurpresa.setActionCommand("");
        buttonSurpresa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSurpresaActionPerformed(evt);
            }
        });

        buttonRaiva.setBackground(new java.awt.Color(153, 0, 0));
        buttonRaiva.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonRaiva.setText("RAIVA");
        buttonRaiva.setActionCommand("");
        buttonRaiva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRaivaActionPerformed(evt);
            }
        });

        buttonNojo.setBackground(new java.awt.Color(102, 0, 102));
        buttonNojo.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonNojo.setText("NOJO");
        buttonNojo.setActionCommand("");
        buttonNojo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonNojoActionPerformed(evt);
            }
        });

        labelStatus.setText("labelStatus");

        buttonAlegria.setBackground(new java.awt.Color(0, 102, 0));
        buttonAlegria.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonAlegria.setText("ALEGRIA");
        buttonAlegria.setActionCommand("");
        buttonAlegria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAlegriaActionPerformed(evt);
            }
        });

        buttonAlegria1.setBackground(new java.awt.Color(0, 102, 0));
        buttonAlegria1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonAlegria1.setText("ALEGRIA");
        buttonAlegria1.setActionCommand("");
        buttonAlegria1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAlegria1ActionPerformed(evt);
            }
        });

        buttonTristeza1.setBackground(new java.awt.Color(51, 51, 255));
        buttonTristeza1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonTristeza1.setText("TRISTEZA");
        buttonTristeza1.setActionCommand("");
        buttonTristeza1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTristeza1ActionPerformed(evt);
            }
        });

        buttonNojo1.setBackground(new java.awt.Color(102, 0, 102));
        buttonNojo1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonNojo1.setText("NOJO");
        buttonNojo1.setActionCommand("");
        buttonNojo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonNojo1ActionPerformed(evt);
            }
        });

        buttonMedo1.setBackground(new java.awt.Color(255, 255, 0));
        buttonMedo1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonMedo1.setText("MEDO");
        buttonMedo1.setActionCommand("");
        buttonMedo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonMedo1ActionPerformed(evt);
            }
        });

        buttonSurpresa1.setBackground(new java.awt.Color(255, 102, 0));
        buttonSurpresa1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonSurpresa1.setText("SURPRESA");
        buttonSurpresa1.setActionCommand("");
        buttonSurpresa1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSurpresa1ActionPerformed(evt);
            }
        });

        buttonRaiva1.setBackground(new java.awt.Color(153, 0, 0));
        buttonRaiva1.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonRaiva1.setText("RAIVA");
        buttonRaiva1.setActionCommand("");
        buttonRaiva1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRaiva1ActionPerformed(evt);
            }
        });

        buttonPausarJogo.setText("Pausar Jogo");
        buttonPausarJogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonPausarJogoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelJogoLayout = new javax.swing.GroupLayout(panelJogo);
        panelJogo.setLayout(panelJogoLayout);
        panelJogoLayout.setHorizontalGroup(
            panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelJogoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelStatus)
                    .addGroup(panelJogoLayout.createSequentialGroup()
                        .addGroup(panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(buttonTristeza, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(buttonNojo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(buttonMedo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(buttonSurpresa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(buttonRaiva, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(buttonAlegria, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(labelImagem, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(buttonTristeza1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(buttonNojo1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(buttonMedo1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(buttonSurpresa1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(buttonRaiva1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(buttonAlegria1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(buttonPausarJogo, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addGap(7, 7, 7))
        );
        panelJogoLayout.setVerticalGroup(
            panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelJogoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelStatus)
                .addGroup(panelJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelJogoLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonAlegria1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonTristeza1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonNojo1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonMedo1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonSurpresa1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonRaiva1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(105, 105, 105)
                        .addComponent(buttonPausarJogo))
                    .addGroup(panelJogoLayout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(labelImagem, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelJogoLayout.createSequentialGroup()
                        .addGap(136, 136, 136)
                        .addComponent(buttonAlegria, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonTristeza, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonNojo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonMedo, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonSurpresa, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonRaiva, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonTristeza.getAccessibleContext().setAccessibleName("");
        buttonMedo.getAccessibleContext().setAccessibleName("");
        buttonSurpresa.getAccessibleContext().setAccessibleName("");
        buttonRaiva.getAccessibleContext().setAccessibleName("");
        buttonNojo.getAccessibleContext().setAccessibleName("");
        buttonAlegria.getAccessibleContext().setAccessibleName("");

        textFimDeJogo.setText("Fim de Jogo! Obrigado por jogar.");

        buttonFinalizarJogo1.setText("Finalizar Jogo");
        buttonFinalizarJogo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonFinalizarJogo1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelFimJogoLayout = new javax.swing.GroupLayout(panelFimJogo);
        panelFimJogo.setLayout(panelFimJogoLayout);
        panelFimJogoLayout.setHorizontalGroup(
            panelFimJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFimJogoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelFimJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(buttonFinalizarJogo1)
                    .addComponent(textFimDeJogo))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelFimJogoLayout.setVerticalGroup(
            panelFimJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFimJogoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textFimDeJogo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonFinalizarJogo1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonIniciarFaseJogo.setText("Iniciar Fase do Jogo");
        buttonIniciarFaseJogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonIniciarFaseJogoActionPerformed(evt);
            }
        });

        labelPercentualAcerto.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        labelPercentualAcerto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelPercentualAcerto.setText("Seu percentual de acerto foi: 0%");

        javax.swing.GroupLayout panelTrocaFaseSubFaseLayout = new javax.swing.GroupLayout(panelTrocaFaseSubFase);
        panelTrocaFaseSubFase.setLayout(panelTrocaFaseSubFaseLayout);
        panelTrocaFaseSubFaseLayout.setHorizontalGroup(
            panelTrocaFaseSubFaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTrocaFaseSubFaseLayout.createSequentialGroup()
                .addGroup(panelTrocaFaseSubFaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelTrocaFaseSubFaseLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(labelPercentualAcerto, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))
                    .addGroup(panelTrocaFaseSubFaseLayout.createSequentialGroup()
                        .addGroup(panelTrocaFaseSubFaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelTrocaFaseSubFaseLayout.createSequentialGroup()
                                .addGap(121, 121, 121)
                                .addComponent(buttonIniciarFaseJogo, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(panelTrocaFaseSubFaseLayout.createSequentialGroup()
                                .addGap(45, 45, 45)
                                .addComponent(labelEstrela1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(labelEstrela2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(labelEstrela3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        panelTrocaFaseSubFaseLayout.setVerticalGroup(
            panelTrocaFaseSubFaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTrocaFaseSubFaseLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelPercentualAcerto)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonIniciarFaseJogo, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(panelTrocaFaseSubFaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelEstrela3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelEstrela2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelEstrela1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonConfirmarContinuar.setText("Confirmar e Continuar");
        buttonConfirmarContinuar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonConfirmarContinuarActionPerformed(evt);
            }
        });

        jLabel1.setText("Tempo de apresentação da imagem (em segundos):");

        textTempoApresentacaoImagem.setText("5");

        jLabel2.setText("Tempo transição de imagens (em segundos):");

        textTempoTransicaoImagens.setText("2");

        jLabel3.setText("Repetir a apresentação de uma imagem ");

        textRepetirApresentacaoImagens.setText("4");

        jLabel4.setText("vez(es)");

        jLabel5.setText("Porcentagem de acertos para avançar para próximas sub-fases:\n(máximo: 100; mínimo: 0)");

        textPercAvancarSubFases.setText("0");
        textPercAvancarSubFases.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textPercAvancarSubFasesActionPerformed(evt);
            }
        });

        checkBoxApresentarMensagemAcertoErro.setSelected(true);
        checkBoxApresentarMensagemAcertoErro.setText("Apresentar mensagens de Acerto/Erro (Na transição de imagens)");

        comboBoxModoJogo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "< Escolha um Modo de Jogo >" }));
        comboBoxModoJogo.setToolTipText("");
        comboBoxModoJogo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboBoxModoJogoItemStateChanged(evt);
            }
        });

        jLabel6.setText("Jogador:");

        textNomeJogador.setEditable(false);

        buttonSelecaoJogador.setText("Selecionar Jogador");
        buttonSelecaoJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSelecaoJogadorActionPerformed(evt);
            }
        });

        jLabel7.setText("Modo de Jogo:");

        jLabel10.setText("%");

        javax.swing.GroupLayout panelParametrosLayout = new javax.swing.GroupLayout(panelParametros);
        panelParametros.setLayout(panelParametrosLayout);
        panelParametrosLayout.setHorizontalGroup(
            panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelParametrosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelParametrosLayout.createSequentialGroup()
                        .addComponent(buttonConfirmarContinuar)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(panelParametrosLayout.createSequentialGroup()
                        .addGroup(panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelParametrosLayout.createSequentialGroup()
                                .addComponent(textPercAvancarSubFases, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10))
                            .addGroup(panelParametrosLayout.createSequentialGroup()
                                .addComponent(textNomeJogador, javax.swing.GroupLayout.PREFERRED_SIZE, 318, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(buttonSelecaoJogador))
                            .addComponent(jLabel5)
                            .addComponent(checkBoxApresentarMensagemAcertoErro)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(comboBoxModoJogo, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addGroup(panelParametrosLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(textRepetirApresentacaoImagens, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4))
                            .addComponent(textTempoApresentacaoImagem, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textTempoTransicaoImagens, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(39, 66, Short.MAX_VALUE))))
        );
        panelParametrosLayout.setVerticalGroup(
            panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelParametrosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textTempoApresentacaoImagem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textTempoTransicaoImagens, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(textRepetirApresentacaoImagens, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(checkBoxApresentarMensagemAcertoErro)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelParametrosLayout.createSequentialGroup()
                        .addGroup(panelParametrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textNomeJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonSelecaoJogador))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboBoxModoJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textPercAvancarSubFases, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonConfirmarContinuar)
                .addContainerGap(124, Short.MAX_VALUE))
        );

        buttonNovoJogador.setText("Novo Jogador");
        buttonNovoJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonNovoJogadorActionPerformed(evt);
            }
        });

        tableJogadores.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Nome"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Long.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tableJogadores);

        buttonSelecionarJogador.setText("Selecionar Jogador");
        buttonSelecionarJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSelecionarJogadorActionPerformed(evt);
            }
        });

        buttonCancelarSelecaoJogador.setText("Cancelar");
        buttonCancelarSelecaoJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCancelarSelecaoJogadorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelSelecaoJogadorLayout = new javax.swing.GroupLayout(panelSelecaoJogador);
        panelSelecaoJogador.setLayout(panelSelecaoJogadorLayout);
        panelSelecaoJogadorLayout.setHorizontalGroup(
            panelSelecaoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelSelecaoJogadorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelSelecaoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonNovoJogador)
                    .addComponent(buttonSelecionarJogador)
                    .addComponent(buttonCancelarSelecaoJogador))
                .addContainerGap())
        );
        panelSelecaoJogadorLayout.setVerticalGroup(
            panelSelecaoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSelecaoJogadorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSelecaoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelSelecaoJogadorLayout.createSequentialGroup()
                        .addComponent(buttonNovoJogador)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonSelecionarJogador)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonCancelarSelecaoJogador)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelNovoJogador.setPreferredSize(new java.awt.Dimension(600, 249));

        jLabel8.setText("Código:");

        textCodigoJogadorCadastro.setAutoscrolls(false);
        textCodigoJogadorCadastro.setDragEnabled(true);

        jLabel9.setText("Nome:");

        buttonSalvarCadastroJogador.setText("Salvar");
        buttonSalvarCadastroJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSalvarCadastroJogadorActionPerformed(evt);
            }
        });

        buttonCancelarCadastroJogador.setText("Cancelar");
        buttonCancelarCadastroJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCancelarCadastroJogadorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelNovoJogadorLayout = new javax.swing.GroupLayout(panelNovoJogador);
        panelNovoJogador.setLayout(panelNovoJogadorLayout);
        panelNovoJogadorLayout.setHorizontalGroup(
            panelNovoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelNovoJogadorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelNovoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelNovoJogadorLayout.createSequentialGroup()
                        .addComponent(buttonSalvarCadastroJogador)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(buttonCancelarCadastroJogador))
                    .addComponent(textNomeJogadorCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelNovoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(textCodigoJogadorCadastro, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(188, Short.MAX_VALUE))
        );
        panelNovoJogadorLayout.setVerticalGroup(
            panelNovoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelNovoJogadorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textCodigoJogadorCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textNomeJogadorCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelNovoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonCancelarCadastroJogador)
                    .addComponent(buttonSalvarCadastroJogador))
                .addContainerGap(107, Short.MAX_VALUE))
        );

        buttonContinuarJogoPausado.setText("Continuar Jogando");
        buttonContinuarJogoPausado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonContinuarJogoPausadoActionPerformed(evt);
            }
        });

        labelJogoPausado.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        labelJogoPausado.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelJogoPausado.setText("Jogo Pausado");

        buttonFinalizarJogo.setText("Finalizar Jogo");
        buttonFinalizarJogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonFinalizarJogoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelJogoPausadoLayout = new javax.swing.GroupLayout(panelJogoPausado);
        panelJogoPausado.setLayout(panelJogoPausadoLayout);
        panelJogoPausadoLayout.setHorizontalGroup(
            panelJogoPausadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelJogoPausadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelJogoPausadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(buttonFinalizarJogo)
                    .addComponent(buttonContinuarJogoPausado, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelJogoPausado, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelJogoPausadoLayout.setVerticalGroup(
            panelJogoPausadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelJogoPausadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelJogoPausado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonContinuarJogoPausado, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonFinalizarJogo)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonIniciarJogo.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        buttonIniciarJogo.setText("Clique para Iniciar Jogo");
        buttonIniciarJogo.setBorderPainted(false);
        buttonIniciarJogo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        buttonIniciarJogo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonIniciarJogoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelIniciarJogoLayout = new javax.swing.GroupLayout(panelIniciarJogo);
        panelIniciarJogo.setLayout(panelIniciarJogoLayout);
        panelIniciarJogoLayout.setHorizontalGroup(
            panelIniciarJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelIniciarJogoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonIniciarJogo, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelIniciarJogoLayout.setVerticalGroup(
            panelIniciarJogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelIniciarJogoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonIniciarJogo, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 845, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(panelJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelFimJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelTrocaFaseSubFase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(409, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelParametros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(235, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(22, 22, 22)
                    .addComponent(panelSelecaoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(255, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(239, Short.MAX_VALUE)
                    .addComponent(panelNovoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(6, 6, 6)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelJogoPausado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(409, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelIniciarJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(409, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 700, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 28, Short.MAX_VALUE)
                    .addComponent(panelJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 28, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelFimJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelTrocaFaseSubFase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(447, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelParametros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(191, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(23, 23, 23)
                    .addComponent(panelSelecaoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(181, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(23, 23, 23)
                    .addComponent(panelNovoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelJogoPausado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(533, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(panelIniciarJogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(559, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowStateChanged

    private void buttonAlegriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAlegriaActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(1);
    }//GEN-LAST:event_buttonAlegriaActionPerformed

    private void buttonNojoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNojoActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(3);
    }//GEN-LAST:event_buttonNojoActionPerformed

    private void buttonRaivaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRaivaActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(4);
    }//GEN-LAST:event_buttonRaivaActionPerformed

    private void buttonSurpresaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSurpresaActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(5);
    }//GEN-LAST:event_buttonSurpresaActionPerformed

    private void buttonMedoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMedoActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(2);
    }//GEN-LAST:event_buttonMedoActionPerformed

    private void buttonTristezaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTristezaActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(6);
    }//GEN-LAST:event_buttonTristezaActionPerformed

    private void buttonAlegria1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAlegria1ActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(1);
    }//GEN-LAST:event_buttonAlegria1ActionPerformed

    private void buttonTristeza1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTristeza1ActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(6);
    }//GEN-LAST:event_buttonTristeza1ActionPerformed

    private void buttonNojo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNojo1ActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(3);
    }//GEN-LAST:event_buttonNojo1ActionPerformed

    private void buttonMedo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMedo1ActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(2);
    }//GEN-LAST:event_buttonMedo1ActionPerformed

    private void buttonSurpresa1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSurpresa1ActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(5);
    }//GEN-LAST:event_buttonSurpresa1ActionPerformed

    private void buttonRaiva1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRaiva1ActionPerformed
        // TODO add your handling code here:
        avaliarImagemApresentada(4);
    }//GEN-LAST:event_buttonRaiva1ActionPerformed

    private void buttonIniciarFaseJogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonIniciarFaseJogoActionPerformed
        // TODO add your handling code here:
        ativarPanelJogo();
        jogo.iniciaFaseSubFase(false);
    }//GEN-LAST:event_buttonIniciarFaseJogoActionPerformed

    private void textPercAvancarSubFasesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textPercAvancarSubFasesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textPercAvancarSubFasesActionPerformed

    private void buttonConfirmarContinuarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfirmarContinuarActionPerformed
        // TODO add your handling code here:
        int value;
        try {
            value = Integer.parseInt(textTempoApresentacaoImagem.getText());
            try {
                value = Integer.parseInt(textTempoTransicaoImagens.getText());
                try {
                    value = Integer.parseInt(textRepetirApresentacaoImagens.getText());
                    try {
                        value = Integer.parseInt(textPercAvancarSubFases.getText());
                        if (textNomeJogador.getText().equals("")) {
                            JOptionPane.showMessageDialog(null, "Selecione um Jogador!", "Atenção!", JOptionPane.INFORMATION_MESSAGE);
                        } else if (comboBoxModoJogo.getSelectedItem().equals("< Escolha um Modo de Jogo >")) {
                            JOptionPane.showMessageDialog(null, "Selecione um Modo de Jogo!", "Atenção!", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            ativarPanelInicial();
                        }
                    } catch (NumberFormatException ex) {
                        JOptionPane.showMessageDialog(null, "Valor inválido para o percentual de acertos\npara avançar para próximas sub-fases!", "Erro!", JOptionPane.ERROR_MESSAGE);
                    }
                } catch (NumberFormatException ex) {
                    JOptionPane.showMessageDialog(null, "Valor inválido para a repetição de imagens!", "Erro!", JOptionPane.ERROR_MESSAGE);
                }
            } catch (NumberFormatException ex) {
                JOptionPane.showMessageDialog(null, "Valor inválido para o tempo de transição!", "Erro!", JOptionPane.ERROR_MESSAGE);
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(null, "Valor inválido para o tempo de apresentação!", "Erro!", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_buttonConfirmarContinuarActionPerformed

    private void buttonSelecaoJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSelecaoJogadorActionPerformed
        // TODO add your handling code here:
        ativarPanelSelecaoJogador();
    }//GEN-LAST:event_buttonSelecaoJogadorActionPerformed

    private void comboBoxModoJogoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboBoxModoJogoItemStateChanged
        // TODO add your handling code here:
        textPercAvancarSubFases.setEnabled(true);
        if (comboBoxModoJogo.getSelectedItem() == null
                || (!comboBoxModoJogo.getSelectedItem().equals("Baseline")
                && !comboBoxModoJogo.getSelectedItem().equals("Completo Progressivo")
                && !comboBoxModoJogo.getSelectedItem().equals("Treinamento"))) {
        } else {
            textPercAvancarSubFases.setEnabled(false);
            if (comboBoxModoJogo.getSelectedItem().equals("Completo Progressivo")) {
                textPercAvancarSubFases.setText(String.valueOf(pessoas.getPessoaDAO().buscaPontuacaoMaxUltimoJogo(jogador.getIdPessoa())));
            }
        }
    }//GEN-LAST:event_comboBoxModoJogoItemStateChanged

    private void buttonCancelarSelecaoJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelarSelecaoJogadorActionPerformed
        // TODO add your handling code here:
        ativarPanelParametros();
    }//GEN-LAST:event_buttonCancelarSelecaoJogadorActionPerformed

    private void buttonSelecionarJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSelecionarJogadorActionPerformed
        // TODO add your handling code here:

        if (tableJogadores.getSelectedRowCount() > 0) {
            //Pego o valor da coluna selecionada na tabela, converto para String, converto String para Long, dai faco a pesquisa da pessoa
            jogador = pessoas.localizaPessoa(Long.parseLong((String) tableJogadores.getValueAt(tableJogadores.getSelectedRow(), 0)));
            textNomeJogador.setText(jogador.getNome());
            preencheComboBoxModoJogo(jogador);
            ativarPanelParametros();
        } else {
            JOptionPane.showMessageDialog(null, "Selecione um Jogador", "Atenção!", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_buttonSelecionarJogadorActionPerformed

    private void buttonNovoJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNovoJogadorActionPerformed
        // TODO add your handling code here:
        textCodigoJogadorCadastro.setText("-1");
        ativarPanelNovoJogador();
    }//GEN-LAST:event_buttonNovoJogadorActionPerformed

    private void buttonPausarJogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPausarJogoActionPerformed
        // TODO add your handling code here:
        if (labelImagem.getName().equals("imagemRosto") && labelImagem.getIcon() != null) {
            jogo.pausarJogo();
        }
    }//GEN-LAST:event_buttonPausarJogoActionPerformed

    private void buttonCancelarCadastroJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelarCadastroJogadorActionPerformed
        // TODO add your handling code here:
        ativarPanelSelecaoJogador();
    }//GEN-LAST:event_buttonCancelarCadastroJogadorActionPerformed

    private void buttonSalvarCadastroJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSalvarCadastroJogadorActionPerformed
        // TODO add your handling code here:
        if (textNomeJogadorCadastro.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Digite um nome válido para o Jogador", "Atenção!", JOptionPane.INFORMATION_MESSAGE);
        } else {
            Pessoa pessoa;
            pessoa = new Pessoa();
            pessoa.setIdPessoa(Long.parseLong(textCodigoJogadorCadastro.getText()));
            pessoa.setNome(textNomeJogadorCadastro.getText());
            pessoas.gravaPessoa(pessoa);
            ativarPanelSelecaoJogador();
        }
    }//GEN-LAST:event_buttonSalvarCadastroJogadorActionPerformed

    private void buttonContinuarJogoPausadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonContinuarJogoPausadoActionPerformed
        // TODO add your handling code here:
        ativarPanelJogo();
        jogo.iniciaFaseSubFase(true);
    }//GEN-LAST:event_buttonContinuarJogoPausadoActionPerformed

    private void buttonIniciarJogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonIniciarJogoActionPerformed
        // TODO add your handling code here:
        long idJogo;
        if (buttonIniciarJogo.isEnabled()) {
            buttonIniciarJogo.setEnabled(false);

            preencheJogoTemporario();

            //Grava instancio do jogoTemporario para ele ser pesquisado para um jogo fixo
            if (jogoTemporario.getModoJogo() != 1) {//Se for Treinamento, não gravara nada no Banco de Dados
                idJogo = this.jogoTemporario.gravaInstanciaJogo();
                this.jogoTemporario.getJogoDAO().gravaJogo(jogador.getIdPessoa(), idJogo);
                this.jogo = this.jogoTemporario.getJogoDAO().buscaInstanciaJogo(idJogo);

                this.jogo.setIdJogo(idJogo);
                this.jogo.setTelaInicial(this);
                this.jogo.setLabelImagem(labelImagem);
                this.jogo.setLabelStatus(labelStatus);
            } else {
                this.jogoTemporario.setIdJogo(-1);
                jogo = jogoTemporario;
            }

            contagemRegressivaPlayGame();
        }
    }//GEN-LAST:event_buttonIniciarJogoActionPerformed

    private void buttonFinalizarJogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFinalizarJogoActionPerformed
        // TODO add your handling code here:        
        fecharAplicacao();
    }//GEN-LAST:event_buttonFinalizarJogoActionPerformed

    private void buttonFinalizarJogo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFinalizarJogo1ActionPerformed
        // TODO add your handling code here:
        finalizaAplicacao();
    }//GEN-LAST:event_buttonFinalizarJogo1ActionPerformed

    public void avaliarImagemApresentada(int idExpressao) {
        //if (labelImagem.getIcon() != null) {
        if (labelImagem.getName().equals("imagemRosto") && labelImagem.getIcon() != null) {
            this.jogo.avaliarImagem(idExpressao);
        }
    }

    //Metodo serve apenas para criar um contador para iniciar o jogo
    public void contagemRegressivaPlayGame() {
        Timer timer;
        timer = new Timer();
        timer.schedule(new RemindTaskA(timer), 0, 1 * 1000);
    }

    /**
     * Remove todos os panels
     */
    public void desativarTodosPanels() {
        this.getContentPane().remove(panelIniciarJogo);
        this.getContentPane().remove(panelJogo);
        this.getContentPane().remove(panelFimJogo);
        this.getContentPane().remove(panelTrocaFaseSubFase);
        this.getContentPane().remove(panelParametros);
        this.getContentPane().remove(panelSelecaoJogador);
        this.getContentPane().remove(panelNovoJogador);
        this.getContentPane().remove(panelJogoPausado);
        //gambiarra
        labelPercentualAcerto.setText(""); //Label do panelParametros
        this.repaint();
    }

    public void ativarPanelInicial() {
        desativarTodosPanels();
        centralizarPanel(this, panelIniciarJogo);
        this.getContentPane().add(panelIniciarJogo, BorderLayout.CENTER);
        this.repaint();
    }

    public void ativarPanelJogo() {
        desativarTodosPanels();
        this.getContentPane().add(panelJogo, BorderLayout.CENTER);
        this.repaint();
    }

    public void ativarPanelFimJogo() {
        desativarTodosPanels();
        centralizarPanel(this, panelFimJogo);
        this.getContentPane().add(panelFimJogo, BorderLayout.CENTER);
        this.repaint();
    }

    /**
     * Se porcentagem menor que zero, o label fica com escrita vazia
     *
     * @param mensagem
     */
    public void ativarPanelTrocaFaseSubFase(String mensagem) {
        long percAcerto = jogo.getFaseEstatica().buscaPorcentagemAcerto();
        String dirImagem = "./banco_de_dados/imagens_sistema/";

        desativarTodosPanels();
        //gambiarra
        labelPercentualAcerto.setText(mensagem);
        labelPercentualAcerto.setHorizontalAlignment(SwingConstants.CENTER);

        ImageIcon ig = new ImageIcon(dirImagem + "estrelaCinza.png");
        //Amplia a imagem fazendo-a ocupar todo o JLabel
        labelEstrela1.setIcon(new ImageIcon(ig.getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)));
        labelEstrela2.setIcon(new ImageIcon(ig.getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)));
        labelEstrela3.setIcon(new ImageIcon(ig.getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)));

        ig = new ImageIcon(dirImagem + "estrelaAmarela.png");
        if (percAcerto >= 0 && percAcerto <= 100) {
            labelEstrela1.setIcon(new ImageIcon(ig.getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)));
        }
        if (percAcerto >= 34 && percAcerto <= 100) {
            labelEstrela2.setIcon(new ImageIcon(ig.getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)));
        }
        if (percAcerto >= 67 && percAcerto <= 100) {
            labelEstrela3.setIcon(new ImageIcon(ig.getImage().getScaledInstance(100, 100, Image.SCALE_DEFAULT)));
        }
        labelEstrela1.repaint();
        labelEstrela2.repaint();
        labelEstrela3.repaint();

        centralizarPanel(this, panelTrocaFaseSubFase);
        this.getContentPane().add(panelTrocaFaseSubFase, BorderLayout.CENTER);
        this.repaint();
    }

    public void ativarPanelParametros() {
        desativarTodosPanels();
        organizarPanelEsquerdaSuperior(panelParametros);
        this.getContentPane().add(panelParametros, BorderLayout.CENTER);
        this.repaint();
    }

    public void ativarPanelSelecaoJogador() {

        if (pessoas != null) {
            pessoas.setPessoas(pessoas.getPessoaDAO().buscaPessoas());
            pessoas.listaPessoas(tableJogadores);
            if (tableJogadores.getRowCount() != 0) {
                tableJogadores.setRowSelectionInterval(0, 0);
            }
        }

        desativarTodosPanels();
        organizarPanelEsquerdaSuperior(panelSelecaoJogador);
        this.getContentPane().add(panelSelecaoJogador, BorderLayout.CENTER);
        this.repaint();
    }

    public void ativarPanelNovoJogador() {
        jLabel8.setVisible(false);
        textCodigoJogadorCadastro.setVisible(false);

        desativarTodosPanels();
        organizarPanelEsquerdaSuperior(panelNovoJogador);
        this.getContentPane().add(panelNovoJogador, BorderLayout.CENTER);
        this.repaint();

        textNomeJogadorCadastro.requestFocus();
    }

    public void ativarPanelJogoPausado() {
        desativarTodosPanels();
        centralizarPanel(this, panelJogoPausado);
        this.getContentPane().add(panelJogoPausado, BorderLayout.CENTER);
        this.repaint();
    }

    public void preencheComboBoxModoJogo(Pessoa pessoa) {
        comboBoxModoJogo.removeAllItems();
        comboBoxModoJogo.addItem("< Escolha um Modo de Jogo >");
        if (pessoa != null) {
            if (pessoa.getQuantidadeJogos() <= 0) {
                comboBoxModoJogo.addItem("Treinamento");
                comboBoxModoJogo.addItem("Baseline");
            } else {
                comboBoxModoJogo.addItem("Completo");
                comboBoxModoJogo.addItem("Completo Progressivo");
            }
        }
    }

    /**
     * Preenche os atributos da variavel jogoTemporario, pois pode-se altera-los
     * mas no final os dados vao ser transferidos para o jogo real
     */
    public void preencheJogoTemporario() {
        this.jogoTemporario.setTelaInicial(this);
        this.jogoTemporario.setLabelImagem(labelImagem);
        this.jogoTemporario.setLabelStatus(labelStatus);
        this.jogoTemporario.setTempoApresentacaoImagens(Integer.parseInt(textTempoApresentacaoImagem.getText()));
        this.jogoTemporario.setTempoTransicaoImagens(Integer.parseInt(textTempoTransicaoImagens.getText()));
        this.jogoTemporario.setRepetirApresentacaoImagens(Integer.parseInt(textRepetirApresentacaoImagens.getText()));
        //No Baseline e no Treinamento o percentual eh sempre zero
        if (comboBoxModoJogo.getSelectedItem() != null && (comboBoxModoJogo.getSelectedItem().equals("Baseline") || comboBoxModoJogo.getSelectedItem().equals("Treinamento"))) {
            this.jogoTemporario.setPercAvancarSubFases(0);
        } else {
            this.jogoTemporario.setPercAvancarSubFases(Integer.parseInt(textPercAvancarSubFases.getText()));
        }
        this.jogoTemporario.setApresentaMensagemAcertoErro(checkBoxApresentarMensagemAcertoErro.isSelected());
        if (comboBoxModoJogo.getSelectedItem().equals("Treinamento")) {
            this.jogoTemporario.setModoJogo(1);
        } else if (comboBoxModoJogo.getSelectedItem().equals("Baseline")) {
            this.jogoTemporario.setModoJogo(2);
        } else if (comboBoxModoJogo.getSelectedItem().equals("Completo")) {
            this.jogoTemporario.setModoJogo(3);
        } else if (comboBoxModoJogo.getSelectedItem().equals("Completo Progressivo")) {
            this.jogoTemporario.setModoJogo(4);
        }
    }

    /**
     * Organiza o panel no lado esquerdo superior do frame
     *
     * @param jPanelInterno
     */
    public void organizarPanelEsquerdaSuperior(JPanel jPanelInterno) {
        jPanelInterno.setSize(jPanelInterno.getPreferredSize());
        jPanelInterno.setLocation(0, 0);
    }

    /**
     * Centraliza o jPanelInterno baseado no 'pai'
     *
     * @param pai
     * @param jPanelInterno
     */
    public void centralizarPanel(Component pai, JPanel jPanelInterno) {
        jPanelInterno.setSize(jPanelInterno.getPreferredSize());
        int x = (pai.getWidth() / 2) - (jPanelInterno.getWidth() / 2);
        int y = (pai.getHeight() / 2) - (jPanelInterno.getHeight() / 2);
        jPanelInterno.setLocation(x, y);
    }

    /**
     * Solicita o fechamento da aplicacao a aplicacao
     */
    public void fecharAplicacao() {
        switch (JOptionPane.showConfirmDialog(null, "Tem certeza que deseja sair ?", "Atenção", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null)) {
            case JOptionPane.YES_OPTION:
                finalizaAplicacao();
                break;
        }
    }

    /**
     * Finaliza a aplicacao
     */
    public void finalizaAplicacao() {
        System.exit(0);
    }

    class RemindTaskA extends TimerTask {

        private Integer segundos;
        private Timer timer;

        public RemindTaskA(Timer timer) {
            this.segundos = 5;
            this.timer = timer;
        }

        @Override
        public void run() {
            buttonIniciarJogo.setText("O jogo começará em " + this.segundos + " segundos.");
            if (this.segundos == 0) {
                ativarPanelJogo();
                jogo.iniciaFaseSubFase(false);

                this.timer.cancel();
            }
            this.segundos--;
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameJogo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameJogo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameJogo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameJogo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameJogo().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAlegria;
    private javax.swing.JButton buttonAlegria1;
    private javax.swing.JButton buttonCancelarCadastroJogador;
    private javax.swing.JButton buttonCancelarSelecaoJogador;
    private javax.swing.JButton buttonConfirmarContinuar;
    private javax.swing.JButton buttonContinuarJogoPausado;
    private javax.swing.JButton buttonFinalizarJogo;
    private javax.swing.JButton buttonFinalizarJogo1;
    private javax.swing.JButton buttonIniciarFaseJogo;
    private javax.swing.JButton buttonIniciarJogo;
    private javax.swing.JButton buttonMedo;
    private javax.swing.JButton buttonMedo1;
    private javax.swing.JButton buttonNojo;
    private javax.swing.JButton buttonNojo1;
    private javax.swing.JButton buttonNovoJogador;
    private javax.swing.JButton buttonPausarJogo;
    private javax.swing.JButton buttonRaiva;
    private javax.swing.JButton buttonRaiva1;
    private javax.swing.JButton buttonSalvarCadastroJogador;
    private javax.swing.JButton buttonSelecaoJogador;
    private javax.swing.JButton buttonSelecionarJogador;
    private javax.swing.JButton buttonSurpresa;
    private javax.swing.JButton buttonSurpresa1;
    private javax.swing.JButton buttonTristeza;
    private javax.swing.JButton buttonTristeza1;
    private javax.swing.JCheckBox checkBoxApresentarMensagemAcertoErro;
    private javax.swing.JComboBox comboBoxModoJogo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel labelEstrela1;
    private javax.swing.JLabel labelEstrela2;
    private javax.swing.JLabel labelEstrela3;
    private javax.swing.JLabel labelImagem;
    private javax.swing.JLabel labelJogoPausado;
    private javax.swing.JLabel labelPercentualAcerto;
    private javax.swing.JLabel labelStatus;
    private javax.swing.JPanel panelFimJogo;
    private javax.swing.JPanel panelIniciarJogo;
    private javax.swing.JPanel panelJogo;
    private javax.swing.JPanel panelJogoPausado;
    private javax.swing.JPanel panelNovoJogador;
    private javax.swing.JPanel panelParametros;
    private javax.swing.JPanel panelSelecaoJogador;
    private javax.swing.JPanel panelTrocaFaseSubFase;
    private javax.swing.JTable tableJogadores;
    private javax.swing.JTextField textCodigoJogadorCadastro;
    private javax.swing.JLabel textFimDeJogo;
    private javax.swing.JTextField textNomeJogador;
    private javax.swing.JTextField textNomeJogadorCadastro;
    private javax.swing.JTextField textPercAvancarSubFases;
    private javax.swing.JTextField textRepetirApresentacaoImagens;
    private javax.swing.JTextField textTempoApresentacaoImagem;
    private javax.swing.JTextField textTempoTransicaoImagens;
    // End of variables declaration//GEN-END:variables
}
